<template>
  <div>
<!--    头部-->
    <div style="min-width:1350px;width:100%;background-color:#336699;display: flex;justify-content:space-between; height: 60px; line-height: 60px;">
      <div style="width: 300px; display: flex; margin-left: 30px;background-color:#336699 ">
        <div style="width: 60px">
          <img src="../../assets/logo.png" alt="xxx" style="width: 50px; position: relative; top: 5px; right: 0">
        </div>
        <div style="color: #ffffff">欢迎来到xx系统</div>
      </div>

      <div style="width: 800px; height: 60px;">
        <el-menu
                class="el-menu-demo"
                :default-active="'/front/home'"
                mode="horizontal"
                background-color="#336699"
                text-color="white"
                active-text-color="#409EFF"
                router>
          <el-menu-item index="/front/home">首页</el-menu-item>
          <el-menu-item index="/front/video">视频播放</el-menu-item>
          <el-menu-item index="/front/article">文章列表</el-menu-item>
          <el-submenu index="2">
            <template slot="title">我的工作台</template>
            <el-menu-item index="/front/item1">选项1</el-menu-item>
            <!--   <el-submenu index="2-4">
                 <template slot="title">选项4</template>
                 <el-menu-item index="2-4-1">选项1</el-menu-item>
               </el-submenu>-->
          </el-submenu>
          <el-menu-item index="3" disabled>消息中心</el-menu-item>
        </el-menu>
      </div>

      <div style="width: 250px;background-color:#336699">
        <!--前台页面可以不登录就访问-->
        <div v-if="!user.username" style="text-align: right; padding-right: 30px">
          <el-button @click="$router.push('/login')">登录</el-button>
          <el-button @click="$router.push('/register')">注册</el-button>
        </div>
        <div v-else>
          <el-dropdown style="width: 150px; cursor: pointer; text-align: right">
            <div style="display: inline-block">
              <img :src="user.avatarUrl" alt=""
                   style="width: 30px; border-radius: 50%; position: relative; top: 10px; right: 5px">
              <span style="color: #ffffff">用户名：{{ user.nickname }}</span><i class="el-icon-arrow-down" style="margin-left: 5px"></i>
            </div>
            <el-dropdown-menu slot="dropdown" style="width: 100px; text-align: center">
              <el-dropdown-item style="font-size: 14px; padding: 5px 0">
                <router-link to="/front/password">修改密码</router-link>
              </el-dropdown-item>
              <el-dropdown-item style="font-size: 14px; padding: 5px 0">
                <router-link to="/front/person">个人信息</router-link>
              </el-dropdown-item>
              <el-dropdown-item style="font-size: 14px; padding: 5px 0">
                <span style="text-decoration: none" @click="logout">退出</span>
              </el-dropdown-item>

              <el-dropdown-item style="font-size: 14px; padding: 5px 0">
                <router-link to="/">去后台</router-link>
              </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </div>
    </div>

    <!--路由配置-->

      <div style="width: 90%;min-width: 1000px;padding: 0 50px">
        <router-view />
      </div>

  </div>
</template>

<script>
export default {
  name: "Front",
  data() {
    return {
      user: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {}
    }
  },
  created() {

  },
  methods: {
    logout() {
      this.$store.commit("logout")
      this.$message.success("退出成功")
    }
  }
}
</script>

<style>
.item{
  display: inline-block;
  width: 100px;

  text-align: center;
  cursor: pointer
}
.item a {
  color:#1E90FF;
}
.item:hover{
  background-color:LightPink;
}
</style>
